<?php
/**
 * ImportController.php
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Install
 */

/** base class */
require_once 'Madoqua/Controller/Action/Abstract.php';

/**
 * Install_ImportController
 * 
 * importing abstract
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  Install
 */
class Install_ImportController extends Madoqua_Controller_Action_Abstract 
{
    public function init()
    {
        $dbAdapter = Zend_Db::factory($this->_getParam('adapter'), array('host'     => $this->_getParam('host'),
                                                                         'username' => $this->_getParam('username'),
                                                                         'password' => $this->_getParam('password'),
                                                                         'dbname'   => $this->_getParam('dbname')));
        
        $tableParams = array('prefix'  => $this->_getParam('prefix'),
                             'adapter' => $dbAdapter);
        
        $importAdapterName = 'Import_Adapter_' . $this->_getParam('source');
        $adapter = new $importAdapterName;
        $adapter->import($tableParams);
    }
}